<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="//s1.music.126.net/style/favicon.ico?v20180823">
    <title>搜索音乐</title>
    <!-- <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css"> -->
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/index.css">
    <link rel="stylesheet" href="css/animate.css">
    <link rel="stylesheet" href="css/article.css">
    <link rel="stylesheet" href="css/eye.css">
    <link rel="stylesheet" href="css/search.css">
    <!-- 音乐播放器 -->
    <link href="css/player.css" rel="stylesheet" type="text/css" />
</head>

<body>
    <!-- toast弹窗 -->
    <div class="toast_success">
        <span class="glyphicon glyphicon-ok-sign"></span>
        <p>操作成功！</p>
    </div>

    <div class="toast_error">
        <div class="glyphicon glyphicon-remove-sign"></div>
        <p>操作失败！</p>
    </div>
    <!-- 音乐播放器尾 -->

    <!-- 搜索音乐 -->
    <div id="search">
        <div class="container" >
            <div class="row">
                <div class="form-group">
                    <label for="gqss" class="col-sm-2 control-label">歌曲搜索</label>
                    <div class="col-sm-10">
                        <input type="text" :placeholder="showKeyword" v-model="songName" @keyup.enter="getSong" name=""
                            id="gqss" class="form-control" value="" required="required" pattern="" title="">
                    </div>
                </div>
            </div>
    
            <div class="row" v-cloak>
    
                <table class="table table-condensed table-striped table-hover" >
                    <thead>
                        <tr>
                            <th>歌名</th>
                            <th>发布时间</th>
                        </tr>
                    </thead>
                    <tbody v-if="songArr.length" >
                        <tr v-for="(item, index) in songArr" :key="index">
                            <td><a href="javascript:;" v-html="item.name" @click="playMusic(item.id,$event)"></a></td>
                            <td> <span>{{item.publishTime | dateTime(item.publishTime)}}</span></td>
                        </tr>
                    </tbody>
                    <tfoot v-else>
                        <td colspan="2">空空如也哦</td>
                    </tfoot>
                </table>
                <audio v-if="musicUrl" :src="musicUrl" id="myaudio" controls="controls" autoplay style="width: 100%;"></audio>
            </div>
        </div>
    </div>

    <script src="node_modules/jquery/dist/jquery.min.js"></script>
    <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="node_modules/axios/dist/axios.min.js"></script>
    <script src="node_modules/vue/dist/vue.min.js"></script>
    <script src="node_modules/swiper/swiper-bundle.js"></script>

    <script src="js/api.js"></script>
    <script src="js/public.js"></script>

   
    <!-- 请求接口 -->
    <script>
        console.log('-------------用于测试接口------------');
        // 推荐歌单
        axios.get('/personalized', { params: { limit: 10 } }).then(res => {
            console.log('推荐歌单');
            console.log(res.data.result);
        });
        //获取歌曲详情
        axios.get('/song/detail', { params: { ids: 347230 } }).then(res => {
            console.log('获取歌曲详情');
            console.log(res.data);
        });
        // 推荐新音乐
        axios({
            url: '/personalized/newsong',
            params: { limit: 10 }
        }).then(res => {
            console.log('推荐新音乐');
            console.log(res.data.result);
        });
        // 获取音乐 url
        axios({
            url: '/song/url',
            params: { id: 188057 }
        }).then(res => {
            console.log('获取音乐 url');
            console.log(res.data.data);
        });
        // 音乐是否可用
        axios({
            url: '/check/music',
            params: { id: 188057 }
        }).then(res => {
            console.log('音乐是否可用');
            console.log(res.data);
        }).catch(err => {
            console.error('歌曲不存在');
        });
        // 搜索
        axios({
            url: '/cloudsearch',
            params: { keywords: '游山恋' }
        }).then(res => {
            console.log('搜索');
            console.log(res.data.result);
        });
        console.log('-------------------------');
    </script>
</body>
</html>